/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-03-03
 * Time: 12:32
 */
public class test1 {
    /**
     * LeetCode 88  合并两个有序数组
     */

    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int i = 0;
        int j = 0;
        int[] sorted = new int[m+n];
        int cur;
        while(i<m || j<n){
            if(i==m){
                cur = nums2[j++];
            }else if(j==n){
                cur = nums1[i++];
            }else if(nums1[i]<nums2[j]){
                cur = nums1[i++];
            }else{
                cur = nums2[j++];
            }
            sorted[i+j-1] = cur;
        }
        for(int k=0;k<m+n;k++){
            nums1[k] = sorted[k];
        }
    }
}
